﻿using Assets.Scripts.DL.Consts;
using Assets.Scripts.DL.Mgrs;
using Unity.VisualScripting;

public class PlayerRunPunch : PlayerBaseState {
	public PlayerRunPunch(PlayerController controller, PlayerStateEnum stateName, State<PlayerStateEnum> superFSM, StateFactory<PlayerStateEnum> factory) : base(controller, stateName, superFSM, factory) {
		AddConditionToSelf(() => _controller.StateData.IsCurHandAtk && !IsZero(_controller.XInput));
	}

	public override void Enter() {
		_controller.PlayAnim(PlayerStateEnum.RunPunch);
		AudioManager.Play(_controller.Effect, AudioStr.RunPunchAudio);
		AudioManager.Play(_controller.StateAudio, AudioStr.PlayerHandAtk3Audio);
		_controller.StateData.CanChangeDir = false;
		_senddmg = false;
	}
	bool _senddmg;
	public override void Update() {
		base.Update();
		if (_controller.IsAnimPlayAt(0.5f) && !_senddmg) {
			_senddmg = true;
			_controller.CheckAtk(_controller.ConfigData.PunchOff, _controller.ConfigData.PunchRad, _controller.ConfigData.PunchDamage);
		}
	}
	public override void Exit() {
		_controller.StateData.CanChangeDir = true;
	}
}